<template>
	<view class="personalData">
		<view class="real-title">注：为有效保障您的资金安全，提升订单处理效率，请填写与您身份证一致的信息，否则不会通过审核。</view>
		<main>
			<view>姓名<input v-model="form.real_name" type="text" :disabled="realDisable"><u-icon name="arrow-right" color="#999999"
					size="11"></u-icon></view>
			<view>手机号<input v-model="form.mobile" type="number" :disabled="realDisable"><u-icon name="arrow-right"
					color="#999999" size="11"></u-icon>
			</view>
			<view>身份证<input v-model="form.cards" type="text" :disabled="realDisable" ><u-icon name="arrow-right" color="#999999"
					size="11"></u-icon>
			</view>
			<view>银行卡号<input v-model="form.bank_no" type="number" :disabled="realDisable"><u-icon name="arrow-right"
					color="#999999" size="11"></u-icon>
			</view>
			<view>银行名称<input v-model="form.bank_name" type="text" :disabled="realDisable"><u-icon name="arrow-right"
					color="#999999" size="11"></u-icon>
			</view>
		</main>
		<button @click="setUserInfo" v-if="!realDisable">开始认证</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					real_name: "",
					bank_no: "",
					mobile: "",
					cards: "",
					bank_name:""
				},
				img: '',
				show: false,
				realDisable:false
			};
		},
		onShow() {
			this.getUserInfo()
		},
		methods: {
			getUserInfo() {
				this.$http.post(this.$api.getUserInfo,{},{token:true}).then(res => {
					if(!res.data.is_auth){
						this.realDisable = false
					}else{
						this.realDisable = true
					}
					this.form = res.data
				})
			},
			setUserInfo() {
				if(!this.form.real_name){
					uni.showToast({
						title:'请填写姓名',
						icon:'none'
					})
					return false
				}
				if(!this.form.mobile){
					uni.showToast({
						title:'请填写手机号',
						icon:'none'
					})
					return false
				}
				if(!this.form.cards){
					uni.showToast({
						title:'请填写身份证号',
						icon:'none'
					})
					return false
				}
				if(!this.form.bank_no){
					uni.showToast({
						title:'请填写银行卡号',
						icon:'none'
					})
					return false
				}
				if(!this.form.bank_name){
					uni.showToast({
						title:'请填写银行名称',
						icon:'none'
					})
					return false
				}
				this.$http.post(this.$api.auth,this.form,{token:true}).then(res => {
					if(res.code == 1){
						uni.showToast({
							title:"提交成功 等待后台审核",
							icon:'none'
						})
						setTimeout(function(){
							uni.switchTab({
								url:'/pages/index/index'
							})
						},1000)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.personalData {
		padding-top: 50rpx;
		// background-color:;
		height: 100vh;
		.real-title {
			font-size: 13px;
			line-height: 1.8;
			color: #ffffff;
			margin: 0rpx 30rpx 30rpx 30rpx;
		}

		&>button {
			width: 690rpx;
			height: 88rpx;
			color: #333333;
			background: #FFF0CA;
			font-size: 16px;
			letter-spacing: 2px;
			border-radius: 44rpx;
			line-height: 88rpx;
			margin-top: 178rpx;
		}

		&>main {
			width: 690rpx;
			padding: 0 20rpx;
			background: #fff;
			border-radius: 20rpx;
			margin: 0 auto;
			box-sizing: border-box;

			&>view {
				padding: 20rpx;
				width: 100%;
				box-sizing: border-box;
				border-bottom: 1px solid #E4E4E4;
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-size: 13px;

				&>input {
					flex: 1;
					height: 100%;
					text-align: right;
					padding-right: 20rpx;
				}

				&>p {
					display: flex;

					&>b {
						font-size: 15px;
						margin-right: 24rpx;
					}

					&>span {
						width: 80rpx;
						height: 80rpx;
						border-radius: 12px;
						margin-right: 28rpx;
						background: #CDCDCD;
						display: flex;
						align-items: center;
						justify-content: center;

						&>image {
							width: 36rpx;
							height: 34rpx;
						}
					}

					&>img {
						width: 80rpx;
						height: 80rpx;
						border-radius: 12px;
						margin-right: 28rpx;
					}
				}
			}
		}
	}
</style>